﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HDI.Charts2
{
    public class CategoryAxis : Dictionary<string, string>
    {
        public Chart Chart;

        public CategoryAxis(Chart chart)
        {
            Chart = chart;
        }

        public void setOption(string key, string value)
        {
            if (!this.Keys.Contains(key))
            {
                this.Add(key, value);
            }
            else
            {
                this[key] = value;
            }
        }

        public string getJS()
        {
            StringBuilder output = new StringBuilder(String.Format("\n\nvar {0}_categoryAxis = {0}_chart.categoryAxis;\n", Chart.ClientID));

            foreach (KeyValuePair<string, string> option in this)
                output.Append(String.Format("{0}_categoryAxis." + option.Key + " = " + option.Value + ";\n", Chart.ClientID));
           // output.Append(String.Format("{0}_chart.addCategoryAxis({0}_categoryAxis);\n", Chart.ClientID));
            return output.ToString();
        }
    }
}
